/*
 * TraceInitializer.c
 *
 *  Created on: 2012/06/07
 *      Author: guanxiaoying
 */
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "../tracedef.h"
#include "TraceAst.h"
S4 TraceInitExpList( VOID ){
	S4 iRet = TRACEEXIT_SUCCESS;
	AST astMaxKind;
	AST astTraceStackUpon;
	U2 usRet;

	if(lEventSec & EVT_INITIALIZER )
	{
		iRet = pfunc( stCurrTraceInfo.usKind, stCurrTraceInfo.astTable , lEvent | EVT_INITIALIZER );
		if(iRet> TRACEEXIT_WARNING)
		{
			return(iRet);
		}
	}
	astMaxKind = stTraceStackAccess.getMax();
	usRet = stTraceStackAccess.kind.get(astMaxKind);
	astTraceStackUpon = stTraceStackAccess.currObject.get(astMaxKind);
	if( astTraceStackUpon != stCurrTraceInfo.astTable
			|| usRet !=  stCurrTraceInfo.usKind ){
		 /*式文をSTACKへPUSHする*/
		/*debug,12/11/14,S*/
		stCurrTraceInfo.astNext = CInitializer.getNextOne( stCurrTraceInfo.astTable );
		/*debug,12/11/14,E*/
		iRet = TraceStack( STACK_PUSH );
		if( iRet > TRACEEXIT_WARNING )
		{
			return iRet;
		}
		astMaxKind = stTraceStackAccess.getMax();
		/* 式文のトレース回数を1とする */
		stTraceStackAccess.times.set( astMaxKind, 1 );
		/*カレントトレース対象を式文の式とする*/
		if( CInitializer.isBlockInitializer( stCurrTraceInfo.astTable ) ){
			stCurrTraceInfo.usKind = TR_KIND_INITIALIZER;
			stCurrTraceInfo.astTable =  CInitializer.getChildInitializer( stCurrTraceInfo.astTable  );
			stCurrTraceInfo.astNext = CInitializer.getNextOne( stCurrTraceInfo.astTable ) ;
		}else{
			stCurrTraceInfo.usKind = TR_KIND_EXPRESSION;
			stCurrTraceInfo.astTable =  CInitializer.getExpression( stCurrTraceInfo.astTable  );
		}
	}else{
		/*式文のトレース回数をトレース最大回数とする */
		astMaxKind = stTraceStackAccess.getMax();
		stTraceStackAccess.times.set( astMaxKind, TRACE_OBJECT_END );

		/* カレントトレース対象を空とする */
		stCurrTraceInfo.astNext = 0;
		stCurrTraceInfo.astTable = 0;
	}
	return iRet;
}


